$(function () {
    $.menuSelector('#dishes_dish');

    var $dt = Ifonly.DataTable({
        searching: false,
        c_filter: true,
        ordering: true,
        ajax: {
            url: g.ctx + '/dishes/dish/dt'
        },
        "order": [
            [0, null] //第一列排序图标改为默认
        ],
        "columns": [
            Ifonly.DTKit.auto,
            {
                data: 'path',
                name: 'a.path',
                orderable: false,
                render: Ifonly.DTKit.render('#cover-template', function (full) {
                    var path = full['path'];
                    if (path) {
                        var indexOf = path.lastIndexOf('.');
                        if (indexOf > -1) {
                            var name = path.substring(0, indexOf);
                            var suffix = path.substring(indexOf + 1);
                            full['path_thumb'] = name + "_100x100." + suffix;
                        } else {
                            full['path_thumb'] = path + "_100x100";
                        }
                    } else {
                        full['path_thumb'] = '';
                    }

                })
            },
            {"data": 'name', name: 'd.name'},
            {"data": 'category_name', name: 'c.name'},
            {"data": 'price', name: 'd.price'},
            {"data": 'is_hot', name: 'd.is_hot', render: Ifonly.DTKit.render('#hot-template')},
            {"data": 'status', name: 'd.status', render: Ifonly.DTKit.render('#status-template')},
            {
                "data": 'id',
                "name": 'd.id',
                "orderable": false,
                render: Ifonly.DTKit.render()
            }
        ]
    }, '#data-table', {
        lightbox2: true
    });
});